package health.lm.com.home.presenter;

import android.view.View;
import android.webkit.WebView;

import health.lm.com.component_base.base.mvp.contract.XPresent;
import health.lm.com.component_base.popup.notice.NoticePopUtil;
import health.lm.com.home.activity.InformationActivity;
import health.lm.com.home.entity.InformationEntity;
import health.lm.com.home.entity.SugarEntity;
import health.lm.com.home.model.HomeModel;
import health.lm.com.network.callback.SimpleCallBack;

/**
 * @author GQI
 * @description:
 * @date :2019-07-25 17:27
 */
public class InformationPresenter extends XPresent<InformationActivity> {

    public void getData(String info_id){
        HomeModel.getInstance().informationDetail(info_id, new SimpleCallBack<InformationEntity>() {
            @Override
            public void onSuccess(InformationEntity informationEntity) {
                if (hasV()){
                    getV().setData(informationEntity);
                }
            }
        });
    }
    public void views(String id){
        HomeModel.getInstance().informationViews(id, new SimpleCallBack<Object>() {
            @Override
            public void onSuccess(Object o) {

            }
        });
    }
    public void getSugar(View view, String id){
        HomeModel.getInstance().getSugar(id, new SimpleCallBack<SugarEntity>() {
            @Override
            public void onSuccess(SugarEntity sugarEntity) {
                NoticePopUtil.getInstance().show(getV().mActivity,view,sugarEntity.getSugar(),"");
            }
        });
    }
}
